<script setup>
  import { reactive, onMounted } from "vue";
  import { onLoad, onShareAppMessage } from "@dcloudio/uni-app";
  import {ossImg} from "@/utils/utils";

  const state = reactive({
    src: ''
  })

  const queryParams = reactive({
    shareTitle: '',
    shareCover: ''
  })

  onLoad((options) => {
    Object.assign(queryParams, options)
    console.log('[webview]', options)
  })

  onMounted(() => {
    Object.keys(queryParams).forEach(key => {
      queryParams[key] = decodeURIComponent(queryParams[key])
    })
    state.src = queryParams.src
  })

  onShareAppMessage(() => {
    return {
      title: queryParams.shareTitle,
      imageUrl: queryParams.shareCover,
      path: uni.getStorageSync('JUMP_URL')
    }
  })
</script>

<template>
  <web-view :src="state.src"></web-view>
</template>

<style lang="scss" scoped>

</style>
